package com.example.administrator.dc.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.example.administrator.dc.Activity.ClubDetail;
import com.example.administrator.dc.Bean.Clublist;
import com.example.administrator.dc.Bean.Dataintro;
import com.example.administrator.dc.R;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on */

public class ClubIntroduceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List mDataList;
    private LayoutInflater mLayoutInflater;
    private PopupWindow mPop;
    private int result;
    private String userid;
    private String followid;

    public ClubIntroduceAdapter(Context mContext , List mDataList){
        this. mContext=mContext;
        this.mDataList=mDataList;
        //this.mLayoutInflater=LayoutInflater.from(mContext);
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mLayoutInflater.from(parent.getContext()).inflate(R.layout.clubintro, parent, false);
        return new ClubIntroduceAdapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final Dataintro entity = (Dataintro) mDataList.get(position);
        if (null == entity)
            return;
        final ClubIntroduceAdapter.ViewHolder viewHolder = (ClubIntroduceAdapter.ViewHolder) holder;
        viewHolder.coachname.setText(entity.getName());
        viewHolder.coachintro.setText(entity.getIntroduction());
        if (!"".equals(entity.getThumb())) {
            Picasso.with(mContext).load("http://172.24.10.175/workout/Uploads/" + entity.getThumb()).into( viewHolder.coach_image);;
        }

       /* viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent=new Intent(mContext,ClubDetail.class);
                intent.putExtra("id",entity.getId());
                mContext.startActivity(intent);

            }
        });*/

    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{

        TextView coachname,coachintro;
        ImageView coach_image;
        //  RelativeLayout background;


        public ViewHolder(View itemView) {
            super(itemView);
            coachname= (TextView) itemView.findViewById(R.id.coachName);
            coachintro= (TextView) itemView.findViewById(R.id.coachinfo);
            coach_image= (ImageView) itemView.findViewById(R.id.coachPhoto);

        }
    }

}
